<!--
* description: 保有客户
* author: zouzx
* createdDate: 2019-10-24
-->
<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="保有客户"
      :visible.sync="curPopupsVisible"
      width="1000px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'保有客户'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="isMul"
      />
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/crm/commonComponents/crmPopupsOneTable";
export default {
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  components: {
    OneTableTemplate,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: crmApis.mdmDlrCustInfoQueryGetCustList,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: "查询",
          position: "top"
        },
        {
          compKey: "btnKey2",
          type: "primary",
          size: "small",
          clickEvent: () => this.sendCode(this.codeField, "custName"),
          text: "确认",
          position: "bottom"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          clickEvent: () => this.sendCodeChoose(),
          text: "同步",
          position: "bottom"
        },
        {
          compKey: "btnKey4",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置",
          position: "top"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "客户名称",
          codeField: "custName",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "电话",
          codeField: "phone",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey3",
          labelName: "车牌号",
          codeField: "carLicenseNo",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey4",
          labelName: "VIN码",
          codeField: "vin",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey5",
          labelName: "发动机号",
          codeField: "engineNo",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey6",
          labelName: "车辆品牌",
          codeField: "carBrandCode",
          component: () => import("@/components/org/carBrand/carBrand"),
          type: "dropdownList",
          isMust: true
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "carBrandName",
          label: "车辆品牌",
          width: 120,
          align: "center",
          fixed: true
        },
        {
          prop: "custName",
          label: "客户名称",
          width: 110,
          align: "center",
          fixed: true
        },
        {
          prop: "phone",
          label: "电话",
          width: 120,
          align: "center",
          fixed: true
        },
        //{ prop: "", label: "会员卡号", width: 120, align: "center" },
        { prop: "carLicenseNo", label: "车牌号", width: 120, align: "center" }, //icCardNo
        { prop: "vin", label: "VIN码", width: 150, align: "center" },
        { prop: "carSeriesCn", label: "车系名称", width: 140, align: "center" }, //seCarSeriesName
        //{ prop: "", label: "车型名称", width: 140, align: "center" },//seCarTypeName
        //{ prop: "", label: "颜色", width: 110, align: "center" },//carColorName
        { prop: "engineNo", label: "发动机号", width: 130, align: "center" },
        //{ prop: "", label: "销售日期", width: 150, align: "center" },//invoiceDate
        //{ prop: "", label: "交车日期", width: 150, align: "center" },//deliveryDate
        {
          prop: "custClassName",
          label: "客户类型",
          width: 100,
          align: "center"
        },
        {
          prop: "custNo",
          label: "一元化客户ID",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "dlrCustNo",
          label: "客户ID",
          width: null,
          align: "center",
          hidden: true
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        custName: "",
        phone: "",
        carLicenseNo: "",
        vin: "",
        engineNo: "",
        carBrandCode: "",
        oemCode: "1",
        groupCode: "1",
        isCarowner: "1"
      },
            //双击事件
      handleTableRowData:{
        value:this.codeField,
        text:"custName"
      }
    };
  },
  methods: {
    sendCodeChoose() {
      debugger;
      if (this.$refs.multipleTable.list == null) {
        this.$alert("没有需要同步的数据", "信息提示", {
          confirmButtonText: "确定",
          type: "warning",
          callback: action => {}
        });
      } else if (this.$refs.multipleTable.currentRow == null) {
        this.$alert("请选择一条数据同步会员信息！", "信息提示", {
          confirmButtonText: "确定",
          type: "warning",
          callback: action => {}
        });
      } else {
        //同步会员信息
      }
    }
  }
};
</script>
